#ifndef _APPS_BWM_CCLIENTDATA_H_
#define _APPS_BWM_CCLIENTDATA_H_

#include "cclient.h"

namespace buola { namespace bwm {

template<typename tData>
class CClientData
{
public:
    CClientData()
        :   mSlot(gRoot->AcquireClientDataSlot(this))
    {
    }

    ~CClientData()
    {
        gRoot->ReleaseClientDataSlot(mSlot);
    }

    tData &operator[](CClient *pClient)
    {
        void *lVoidData=pClient->GetRendererData(mSlot);
        tData *lData=(tData*)lVoidData;
        if(!lData)
        {
            lData=new tData;
            pClient->SetRendererData(mSlot,lData);
        }

        return *lData;
    }

private:
    int mSlot;
};

/*namespace bwm*/ } /*namespace buola*/ }

#endif
